package com.cn.test1.servlet;

import com.cn.test1.model.*;
import com.cn.test1.service.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/news")
public class NewsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        NewsService newsService = new NewsService();
        NewsModel newsModel = newsService.getNewsModel();
        req.setAttribute("newsModel",newsModel);

        List<NewsModel> newsModelImgs = newsService.getNewsImgs();
        req.setAttribute("newsModelImgs",newsModelImgs);

        List<NewsModel> newsModelContent1 = newsService.getNewsContent1();
        req.setAttribute("newsModelContent1",newsModelContent1);

        List<NewsModel> newsModelContent2 = newsService.getNewsContent2();
        req.setAttribute("newsModelContent2",newsModelContent2);

        BuildService buildService = new BuildService();
        List<BuildModel> buildModelNav = buildService.getbuildNav();
        req.setAttribute("buildModelNav",buildModelNav);

        //头部信息
        TopService TopService = new TopService();
        TopModel TopModel = TopService.getTopModel();
        req.setAttribute("TopModel",TopModel);
        //拿到导航信息
        List<TopModel> TopModelList = TopService.getTopModelList();
        req.setAttribute("TopModelList",TopModelList);

        //脚部信息
        FootService footService = new FootService();
        List<FootModel> footModel = footService.getFootModelList();//咨询信息
        req.setAttribute("footModel",footModel);

        List<FootModel> footModelInput = footService.getFootModelListInput();//输入框
        req.setAttribute("footModelInput",footModelInput);

        List<FootModel> footModelMessage = footService.getFootModelMessage();//留言提示信息
        req.setAttribute("footModelMessage",footModelMessage);

        FootModel footModels = footService.getFootModel();//备案信息
        req.setAttribute("footModels",footModels);

        List<FootModel> footModelListImg = footService.getFootModelListImg(); //底部图片
        req.setAttribute("footModelListImg",footModelListImg);

        req.getRequestDispatcher("/jsp/news.jsp").forward(req,resp);

    }
}
